<?php 
namespace addons\prl\service;
use addons\prl\model\Articles as ArticlesModel;
use addons\prl\model\Channels as ChannelsModel;
/**
 * 
 */
class Articles
{
	/**
	 * 获取列表栏目文章列表
	 * @param  integer $channels_id 栏目id
	 * @param  integer $limit       条数
	 * @param  integer $page        页码数
	 * @return array                文章数组
	 */
	static public function getList($channels_id, $limit = 10)
	{
		return ArticlesModel::nomal()->articlesorder()->where('channels_id', $channels_id)->paginate($limit);
	}

	/**
	 * 获取栏目栏目文章列表
	 * @param  integer $channels_id 栏目id
	 * @param  integer $limit       条数
	 * @param  integer $page        页码数
	 * @return array                文章数组
	 */
	static public function getChannelList($channels_id, $limit = 10)
	{
		//获取子栏目id
		$channelIds = ChannelsModel::where('pid',$channels_id)->column('id');
		return ArticlesModel::scope('nomal,articlesorder')->where('channels_id', 'in', $channelIds)->paginate($limit);
	}
}